package com.suyeer.basic.log4j;

import org.apache.log4j.Category;
import org.apache.log4j.Priority;
import org.apache.log4j.jdbc.JDBCAppender;
import org.apache.log4j.spi.LoggingEvent;

/**
 * @author jun 2018/10/19
 */
public class Log4JdbcAppender extends JDBCAppender {

    @Override
    protected String getLogStatement(LoggingEvent event) {
        String fqnOfCategoryClass = event.fqnOfCategoryClass;
        Category logger = event.getLogger();
        Priority level = event.getLevel();
        Object message = event.getMessage();
        Log4JdbcLoggingEvent log4JdbcLoggingEvent = new Log4JdbcLoggingEvent(fqnOfCategoryClass, logger, level, message);
        return super.getLogStatement(log4JdbcLoggingEvent);
    }
}